package com.lzx.reggie.controller

import com.lzx.reggie.common.R
import com.lzx.reggie.entity.Orders
import com.lzx.reggie.service.OrderService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController


@RestController
@RequestMapping("/order")
class OrderController {
    companion object {
        private val log = LoggerFactory.getLogger(OrderController::class.java)
    }

    @Autowired
    private lateinit var orderService: OrderService

    /**
     * 用户下单
     * @param orders
     * @return
     */
    @PostMapping("/submit")
    fun submit(@RequestBody orders: Orders): R<String> {
        log.info("订单数据：$orders")
        orderService.submit(orders)
        return R.success("下单成功")
    }
}